package com.agy.filemanager.controller;

import com.agy.filemanager.common.TreeUtil;
import com.agy.filemanager.configuration.MyInterceptor;
import com.agy.filemanager.entity.DcBaseInfoAgyuser;
import com.agy.filemanager.entity.TreeModel;
import com.agy.filemanager.service.DcSystemAgyOrgUserService;
import com.agy.filemanager.toolClass.Result;
import com.agy.filemanager.toolClass.ResultUtil;
import com.github.pagehelper.Page;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;




/**
 * 系统设置-安工院组织人员
 */
@Controller
@RequestMapping("/systemAgyOrgUser")
public class SystemAgyOrgUserController {

    @Autowired
    private DcSystemAgyOrgUserService dcSystemAgyOrgUserService;

    /**
     * 跳转至安工院组织机构与人员展示页面
     * @return
     */
    @GetMapping("/agyOrgUserInfo")
    public String agyOrgUserInfo(){
        return "agyOrgUser/index";
    }

    /**
     * 分页-获取安工院人员信息
     * @param request
     * @return
     */
    @PostMapping("/agyUserInfo")
    @ResponseBody
    public Map<String,Object> agyUserInfo(HttpServletRequest request){
        int pageSize =Integer.parseInt(request.getParameter("pageSize"));
        int pageNum =Integer.parseInt(request.getParameter("pageNum"));
        String searchName = request.getParameter("searchName");
        String orgId = request.getParameter("orgId");
        Page list = this.dcSystemAgyOrgUserService.agyUserInfo(pageNum,pageSize,searchName,orgId);
        Map<String,Object> map=new HashMap<>();
        map.put("total",list.getTotal());
        map.put("rows",list.getResult());
        return map;
    }

    /**
     * 获取安工院组织机构树
     * @return
     */
    @PostMapping("/agyOrganiseInfo")
    @ResponseBody
    public Result agyOrganiseInfo(){
        List<TreeModel> list = TreeUtil.getTree(this.dcSystemAgyOrgUserService.agyOrganiseInfo());
        return ResultUtil.success(list, "成功");
    }


}
